<?php echo $this->Html->script('Medico'); ?>
<div id="msg"></div>
<form action="/siscel/medicos/pesquisar" id="MEDICOPesquisarForm" method="post">
    <fieldset>
        <legend>Médicos</legend>
        <input type="hidden" name="_method" value="POST"/>
        <table width="98%" border="0" cellspacing="0" cellpadding="2">
            <thead>
                <th colspan="5">
                    <b></b>
                </th>
            </thead>
            <tr>
                <td>
                    <?php echo $this->Form->input('Medico.NM_MEDIC', array('type' => 'text', 'label' => 'Nome', 'id' => 'txtNome', 'class' => 'campoAlfa', 'size' => "30", 'maxlength' => "120")); ?>
                </td>
                <td>
                    <?php echo $this->Form->input('Medico.CD_CRM', array('type' => 'text', 'label' => 'CRM', 'id' => 'txtCDCRM', 'class' => 'campoNumerico', 'size' => "10", 'maxlength' => "9")); ?>
                </td>
                <!-- td>
                    <?php //echo $this->Form->input('Medico.UF_CRM', array('type' => 'select', 'label' => 'UF', 'id' => 'txtUFCRM', 'class' => '', 'options' => $arrUF)); ?>
                </td -->
                <td>
                    <?php echo $this->Form->input('Usuario.STATUS', array('type' => 'select', 'label' => 'Status', 'id' => 'status', 'class' => '', 'options' => array(''=>'Selecione um item','A'=>'Ativo','D'=>'Desativado'))); ?>
                </td>
            </tr>
            <tr>
                <td>                    
                    <?php echo $this->Form->input('Medico.UF_CRM', array('type' => 'select', 'label' => 'Unidade', 'id' => 'txtUnidades', 'class' => '', 'options' => $arrUnidades)); ?>
                </td>
                <td>
                    <?php echo $this->Form->input('Medico.CPF_MEDIC', array('type' => 'text', 'label' => 'CPF', 'id' => 'txtCPF', 'class' => 'campoCPF', 'size' => "30", 'maxlength' => "120")); ?>
                </td>
                <td>
                    <?php echo $this->Form->input('Medico.CNS', array('type' => 'text', 'label' => 'CNS', 'id' => 'txtCNS', 'class' => '', 'size' => "5", 'maxlength' => "5")); ?>
                </td>
                <td>
                </td>
            </tr>
        </table>
        <div class="submit">
            <input id="btPesquisarMedico" type="submit" value="Pesqusiar"/>
        </div>    
    </fieldset>
</form>
<div id="tabelaPesquisa">

        <table id="tbResuldado" class="dataTable" border="0" cellspacing="0" cellpadding="0">
            <thead>
                <th></th>
            </thead>
            <tbody>
                <?php
    if(!empty($arrMedicos)){ ?>
        <?php 
        foreach($arrMedicos as $v){ 
            $cor = 'yellow';
            if($v['AUTORIZADO']['STATUS'] == 'D'){
                $cor = 'red';
            }else{
                if(!empty($v[0]['TELEFONES']) && !empty($v['AUTORIZADO']['DS_EMAIL'])){
                    $cor = 'blue';
                }
            }
            ?>
            <tr>
                <td>
                    <div style="width: 100%">
                        <div style="width: 10%;float: left;clear: right;">
                            <a href="/siscel/medicos/visualizar/<?php echo h($v['MEDICO']['CPF_MEDIC']); ?>">
                                <?php
                                    if(!empty($v['MEDICO']['IM_FOTO'])){
                                        $this->Siscel->foto($v['MEDICO']['IM_FOTO'], 70, 70);
                                    }else{
                                        echo $this->Html->image('/img/perfil.jpg', array('width' => '70', 'height' => '70', 'label' => null, 'style' => 'border: 0;margin: 4px 8px;'));
                                    }
                                ?>
                            </a>
                        </div>
                        <div style="width: 90%;float: left;">
                            <div style="float: left;clear: right;width: 100%;">
                                <table style="width: 100%;border: 0;" border="0" cellspacing="0" cellpadding="0">
                                    <tr>
                                      <td><b>Nome:</b> <a href="/siscel/medicos/visualizar/<?php echo h($v['MEDICO']['CPF_MEDIC']); ?>"><?php echo h($v['MEDICO']['NM_MEDIC']); ?></a></td>
                                      <td><b>CPF:</b> <?php echo h($v['MEDICO']['CPF_MEDIC']); ?></td>
                                      <td><b>CRM:</b> <?php echo h($v['MEDICO']['CD_CRM'].'/'.$v['UF']['NM_UF']); ?></td>
                                      <td><b>CNS:</b> <?php echo h($v['MEDICO']['NU_CNSUS']); ?></td>
                                      <td>
                                        <img src="/siscel/img/bt_apagar.gif" onclick="Medico.excluiMedico('<?php echo h($v['MEDICO']['CPF_MEDIC']); ?>',false)" title="Excluir médico"/>
                                      </td>
                                    </tr>
                                </table>
                            </div>
                            <div style="float: left;clear: right;width: 100%;">
                                <table style="width: 100%;border: 0;" border="0" cellspacing="0" cellpadding="0">
                                    <tr>
                                        <td colspan="5"><b>Unidades:</b> </td>
                                    </tr>
                                </table>
                            </div>
                            <div style="float: left;clear: right;width: 100%;">
                                <table style="width: 100%;border: 0;" border="0" cellspacing="0" cellpadding="0">
                                    <tr>
                                        <td colspan="5" title="<?php echo h($v[0]['TELEFONES']); ?>"><b>Telefones:</b> <?php echo substr(h($v[0]['TELEFONES']), 0, 90).' ...'; ?></td>
                                    </tr>
                                </table>
                            </div>
                        </div>
                    </div>
                </td>
            </tr>                                                                                   
        <?php
        } ?>
             <?php
    }
    ?>
            </tbody>
        </table>        
</div>
<script type="text/javascript">
    $(document).ready(function(){
        Medico.init();
    });
</script>